// ==UserScript==
// @name        League of Legends - Tribunal Helper
// @namespace   LoLTH
// @description Helps with judging cases in the League of Legends Tribunal
// @version     1.0
// @grant none
// @include http://na.leagueoflegends.com/tribunal/en/review/
// ==/UserScript==

console.log("THelper Loaded");
document.getElementsByClassName("reviewing-title")[0].innerHTML = "Tribunal Helper Reviewing Case:";

var TribunalHelper = (function () {
    //put app code in here, this will remove your app from the global scope
	
	var ReportableOffenses = [
		"Offensive Language",
		"Verbal Abuse",
		"Intentional Feeding",
		"Assisting Enemy Team",
		"Refusing to Communicate",
		"AFK",
		"Negative Attitude",
		"Spamming"
	]
	var ProfanityList = [
		"ahole",
		"anus",
		"ashle",
		"ashles",
		"asholes",
		"ass",
		"Ass Monkey",
		"Assface",
		"asshle",
		"asshlez",
		"asshole",
		"assholes",
		"assholz",
		"asswipe",
		"azzhole",
		"bassterds",
		"bastard",
		"bastards",
		"bastardz",
		"basterds",
		"basterdz",
		"Biatch",
		"bitch",
		"bitches",
		"Blow Job",
		"boffing",
		"butthole",
		"buttwipe",
		"cck",
		"ccks",
		"ck",
		"Carpet Muncher",
		"cawk",
		"cawks",
		"Clit",
		"cnts",
		"cntz",
		"cock",
		"cockhead",
		"cock-head",
		"cocks",
		"CockSucker",
		"cock-sucker",
		"crap",
		"cum",
		"cunt",
		"cunts",
		"cuntz",
		"dick",
		"dild",
		"dilds",
		"dildo",
		"dildos",
		"dilld",
		"dillds",
		"dominatricks",
		"dominatrics",
		"dominatrix",
		"dyke",
		"enema",
		"f u c k",
		"f u c k e r",
		"fag",
		"fagt",
		"faget",
		"faggt",
		"faggit",
		"faggot",
		"fagit",
		"fags",
		"fagz",
		"faig",
		"faigs",
		"fart",
		"flipping the bird",
		"fuck",
		"fucker",
		"fuckin",
		"fucking",
		"fucks",
		"Fudge Packer",
		"fuk",
		"Fukah",
		"Fuken",
		"fuker",
		"Fukin",
		"Fukk",
		"Fukkah",
		"Fukken",
		"Fukker",
		"Fukkin",
		"gk",
		"gay",
		"gayboy",
		"gaygirl",
		"gays",
		"gayz",
		"God-damned",
		"hr",
		"har",
		"hre",
		"hells",
		"hoar",
		"hoor",
		"hoore",
		"jackoff",
		"jap",
		"japs",
		"jerk-off",
		"jisim",
		"jiss",
		"jizm",
		"jizz",
		"knob",
		"knobs",
		"knobz",
		"kunt",
		"kunts",
		"kuntz",
		"Lesbian",
		"Lezzian",
		"Lipshits",
		"Lipshitz",
		"masochist",
		"masokist",
		"massterbait",
		"masstrbait",
		"masstrbate",
		"masterbaiter",
		"masterbate",
		"masterbates",
		"Motha Fucker",
		"Motha Fuker",
		"Motha Fukkah",
		"Motha Fukker",
		"Mother Fucker",
		"Mother Fukah",
		"Mother Fuker",
		"Mother Fukkah",
		"Mother Fukker",
		"mother-fucker",
		"Mutha Fucker",
		"Mutha Fukah",
		"Mutha Fuker",
		"Mutha Fukkah",
		"Mutha Fukker",
		"ngr",
		"nastt",
		"nigger;",
		"nigur;",
		"niiger;",
		"niigr;",
		"orafis",
		"orgasim;",
		"orgasm",
		"orgasum",
		"oriface",
		"orifice",
		"orifiss",
		"packi",
		"packie",
		"packy",
		"paki",
		"pakie",
		"paky",
		"pecker",
		"peeenus",
		"peeenusss",
		"peenus",
		"peinus",
		"pens",
		"penas",
		"penis",
		"penis-breath",
		"penus",
		"penuus",
		"Phuc",
		"Phuck",
		"Phuk",
		"Phuker",
		"Phukker",
		"polac",
		"polack",
		"polak",
		"Poonani",
		"prc",
		"prck",
		"prk",
		"pusse",
		"pussee",
		"pussy",
		"puuke",
		"puuker",
		"queer",
		"queers",
		"queerz",
		"qweers",
		"qweerz",
		"qweir",
		"recktum",
		"rectum",
		"retard",
		"sadist",
		"scank",
		"schlong",
		"screwing",
		"semen",
		"sex",
		"sexy",
		"Sh!t",
		"sht",
		"shter",
		"shts",
		"shtter",
		"shtz",
		"shit",
		"shits",
		"shitter",
		"Shitty",
		"Shity",
		"shitz",
		"Shyt",
		"Shyte",
		"Shytty",
		"Shyty",
		"skanck",
		"skank",
		"skankee",
		"skankey",
		"skanks",
		"Skanky",
		"slut",
		"sluts",
		"Slutty",
		"slutz",
		"son-of-a-bitch",
		"tit",
		"turd",
		"vajina",
		"vagna",
		"vagiina",
		"vagina",
		"vajna",
		"vajina",
		"vullva",
		"vulva",
		"wp",
		"whr",
		"whre",
		"whore",
		"xrated",
		"xxx",
		"b!+ch",
		"bitch",
		"blowjob",
		"clit",
		"arschloch",
		"fuck",
		"shit",
		"ass",
		"asshole",
		"b!tch",
		"bch",
		"btch",
		"bastard",
		"bi+ch",
		"boiolas",
		"buceta",
		"cck",
		"cawk",
		"chink",
		"cipa",
		"clits",
		"cock",
		"cum",
		"cunt",
		"dildo",
		"dirsa",
		"ejakulate",
		"fatass",
		"fcuk",
		"fuk",
		"fuxr",
		"hoer",
		"hore",
		"jism",
		"kawk",
		"litch",
		"li+ch",
		"lesbian",
		"masturbate",
		"masterbat*",
		"masterbat",
		"motherfucker",
		"s.o.b.",
		"mofo",
		"nazi",
		"nigga",
		"nigger",
		"nutsack",
		"phuck",
		"pimpis",
		"pusse",
		"pussy",
		"scrotum",
		"sh!t",
		"shemale",
		"shi+",
		"sh!+",
		"slut",
		"smut",
		"teets",
		"tits",
		"boobs",
		"bbs",
		"teez",
		"testical",
		"testicle",
		"titt",
		"wse",
		"jackoff",
		"wank",
		"whoar",
		"whore",
		"*damn",
		"*dyke",
		"*fuck*",
		"*shit*",
		"@$$",
		"amcik",
		"andskota",
		"arse*",
		"assrammer",
		"ayir",
		"bich",
		"bitch*",
		"bollock*",
		"breasts",
		"butt-pirate",
		"cabron",
		"cazzo",
		"chraa",
		"chuj",
		"Cock*",
		"cunt*",
		"dmn",
		"daygo",
		"dego",
		"dick*",
		"dike*",
		"dupa",
		"dziwka",
		"ejackulate",
		"Ekrem*",
		"Ekto",
		"enculer",
		"faen",
		"fag*",
		"fanculo",
		"fanny",
		"feces",
		"feg",
		"Felcher",
		"ficken",
		"fitt*",
		"Flikker",
		"foreskin",
		"Fotze",
		"Fu(*",
		"fuk*",
		"futkretzn",
		"gay",
		"gook",
		"guiena",
		"hr",
		"hxr",
		"hell",
		"helvete",
		"hoer*",
		"honkey",
		"Huevon",
		"hui",
		"injun",
		"jizz",
		"kanker*",
		"kike",
		"klootzak",
		"kraut",
		"knulle",
		"kuk",
		"kuksuger",
		"Kurac",
		"kurwa",
		"kusi*",
		"kyrpa*",
		"lesbo",
		"mamhoon",
		"masturbat*",
		"merd*",
		"mibun",
		"monkleigh",
		"mouliewop",
		"muie",
		"mulkku",
		"muschi",
		"nazis",
		"nepesaurio",
		"nigger*",
		"orospu",
		"paska*",
		"perse",
		"picka",
		"pierdol*",
		"pillu*",
		"pimmel",
		"piss*",
		"pizda",
		"poontsee",
		"poop",
		"porn",
		"prn",
		"prn",
		"preteen",
		"pula",
		"pule",
		"puta",
		"puto",
		"qahbeh",
		"queef*",
		"rautenberg",
		"schaffer",
		"scheiss*",
		"schlampe",
		"schmuck",
		"screw",
		"sh!t*",
		"sharmuta",
		"sharmute",
		"shipal",
		"shiz",
		"skribz",
		"skurwysyn",
		"sphencter",
		"spic",
		"spierdalaj",
		"splooge",
		"suka",
		"bb*",
		"testicle*",
		"titt*",
		"twat",
		"vittu",
		"wank*",
		"wetback*",
		"wichser",
		"wop*",
		"yed",
		"zabourah",
		"f u",
		"noob",
		"nood",
		"noobs",
		"feed",
		"feeder",
		"nerds"
	]

	function ProfanityFinder(message) {
		var pCount = 0;
		for (var i = 0;  i < ProfanityList.length; i++) {
			if (message.contains(ProfanityList[i])) {
				pCount = pCount + 1;
			}
		}
		return pCount;
	}
	
	function SpamFinder() {
		
	}
	
	function FindReportableOffenses() {
		
	}
	
	function FindNumberOfGames() {
		var games = 0;
		games = document.getElementsByClassName("total-games-fill")[0].innerHTML;
		return games;
	}
	
	function FindNumberOfReports() {
		var reports = 0;
		reports = document.getElementsByClassName("total-reports-fill")[0].innerHTML;
		return reports;
	}
	
	function TribunalHelperSuggestion(str) {
		switch (str) {
		case "Pardon":
			return "<span class='ally'>Pardon</span>"
		case "Punish":
			return "<span class='enemy'>Punish</span>"
		default:
			return "<span class='reported-player'>Please Verify By Hand</span>"
		}
	}
 
    //private functions should go here, and will be accessable in your public function
 
    return {
        //put public functions here
 
        run: function () {
			var scoreSummary = 0,
			gameCount = FindNumberOfGames(),
			reportCount = FindNumberOfReports(),
			profanityCount = 0,
			suggestion = "";
			
			console.log("Number of Games: " + gameCount);
			console.log("Number of Reports: " + reportCount);
			jQuery('.tab-content').each(function () {
				var $this = jQuery(this),
				score = 0;

				$this.find('.chat-message').each(function () {
				var $this = jQuery(this),
                $container = $this.parent('tr'),
                message = $this.text(),
                isReportedPlayer = $container.hasClass('reported-player'),
                isAlly = $container.hasClass('ally'),
                isEnemy = $container.hasClass('enemy');

			if (isReportedPlayer) {
				profanityCount = profanityCount + ProfanityFinder(message);
				console.log("Profanity Count:" + profanityCount + " Message:" + message);
			}
			
            //console.log(message, isReportedPlayer, isAlly, isEnemy);
			});

			scoreSummary = scoreSummary + score;
			gameCount = gameCount + 1;
		});

		var average = scoreSummary / gameCount;
		
		if (average > 8) {
			//punish
		} else {
			//skip
		}
	
		var summary = document.getElementsByClassName("total-reports")[0].innerHTML;
		document.getElementsByClassName("total-reports")[0].innerHTML = summary + "<br /><h2>Tribunal Helper Rating: " + scoreSummary + " / 100  <br /> Suggestion: " + TribunalHelperSuggestion(suggestion) +"</h2>";
        }
    };
}());

window.addEventListener('load', function () {
	setTimeout(function() {
		TribunalHelper.run();
	}, 5000);
}, false);
